package com.bdqn.qnnews.search.controller.v1;

import com.bdqn.qnnews.common.base.R;
import com.bdqn.qnnews.search.service.EsDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * http://10.0.0.5:18001/app/search/api/v1/article/search/search/
 * @author xlzhang
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v1/article")
@Tag(name = "es数据同步控制Api")
public class DataSyncController {

    private final EsDataService esDataService;

    @Operation(summary="全量索引数据同步",description="查询所有文章数据库数据，导入到es索引库中")
    @GetMapping("/es-init")
    public R<String> esDataInit(){
        final boolean res = esDataService.dataInit();
        return R.ok("全量索引数据同步完成");
    }
}